package com.mvd.app.ac2021.activitys;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.google.gson.Gson;
import com.kongzue.dialog.interfaces.OnMenuItemClickListener;
import com.kongzue.dialog.util.TextInfo;
import com.kongzue.dialog.v3.BottomMenu;
import com.kongzue.dialog.v3.MessageDialog;
import com.kongzue.dialog.v3.TipDialog;
import com.kongzue.dialog.v3.WaitDialog;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;
import com.lzy.okgo.request.base.Request;
import com.mvd.app.R;
import com.mvd.app.activity.BaseActivity;
import com.mvd.app.activity.WaiJianResultActivity;
import com.mvd.app.application.BaseApplication;
import com.mvd.app.commons.CommonUtils;
import com.mvd.app.commons.DateUtil;
import com.mvd.app.commons.JsonUtil;
import com.mvd.app.commons.PDALogUtils;
import com.mvd.app.commons.SharedPreferencesUtils;
import com.mvd.app.commons.Utils;
import com.mvd.app.commons.UtilsLog;
import com.mvd.app.commons.VehicleCheckUtils;
import com.mvd.app.model.CarItemEndModel;
import com.mvd.app.model.CarItemStartModel;
import com.mvd.app.model.CarsInforModel;
import com.mvd.app.model.CheckItemModel;
import com.mvd.app.model.CodeListModel;
import com.mvd.app.model.Item_2Model;
import com.mvd.app.model.ItemsModel;
import com.mvd.app.model.MyChoiceModel;
import com.mvd.app.model.UpdateCarStatusModel;
import com.mvd.app.model.WaiJainDataModel;
import com.mvd.app.model.WaiJianAddRecordModel;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.iwgang.countuptime.CountupView;

import static com.mvd.app.application.BaseApplication.IsFirst;
import static com.mvd.app.application.BaseApplication.myChoiceModelList;
import static com.mvd.app.application.BaseApplication.mycar_checkItemlList;

//车辆唯一性检查
public class UniquenessActivity extends BaseActivity {
    public UniquenessActivity instances = null;
    @BindView(R.id.ac_uniqueness_online_carno)
    TextView acUniquenessOnlineCarno;
    @BindView(R.id.ac_uniqueness_SN)
    TextView acUniquenessSN;
    @BindView(R.id.ac_uniqueness_online_times)
    TextView acUniquenessOnlineTimes;
    @BindView(R.id.ac_uniqueness_line)
    TextView acUniquenessLine;
    @BindView(R.id.ac_uniqueness_haopai_haoma_fenlei)
    TextView acUniquenessHaopaiHaomaFenlei;
    @BindView(R.id.ac_uniqueness_cheliang_pinpai_xinghao)
    TextView acUniquenessCheliangPinpaiXinghao;
    @BindView(R.id.ac_uniqueness_cheliang_shibie_daihao)
    TextView acUniquenessCheliangShibieDaihao;
    @BindView(R.id.ac_uniqueness_fadongji_haoma)
    TextView acUniquenessFadongjiHaoma;
    @BindView(R.id.ac_uniqueness_cheliang_yanse_cheliang_waixing)
    TextView acUniquenessCheliangYanseCheliangWaixing;
    @BindView(R.id.ac_uniqueness_desc)
    EditText acUniquenessDesc;
    @BindView(R.id.ac_uniqueness_btn_end)
    Button acUniquenessBtnEnd;
    @BindView(R.id.ac_uniqueness_btn_start)
    Button acUniquenessBtnStart;
    @BindView(R.id.ac_uniqueness_btn_paizhao_vin)
    Button acUniquenessBtnPaizhaoVin;
    @BindView(R.id.ac_uni_CountupViewTest3)
    CountupView acUniCountupViewTest3;
    @BindView(R.id.ac_uniqueness_btn_buhege)
    Button acUniquenessBtnBuhege;
    @BindView(R.id.ac_uniqueness_beizhu)
    EditText acUniquenessBeizhu;
    @BindView(R.id.ac_uniqueness_tv_beizhu_more)
    TextView acUniquenessMore;

    String desc = "";//描述
    String beizhu = "";//备注
    String line = "01";
    String error_msg = "", Item_Code = "UC", item_start_time = "", item_end_time = "";
    @BindView(R.id.ac_uniqueness_brand_carModel)
    TextView acUniquenessBrandCarModel;
    @BindView(R.id.ac_uniqueness_EngineNO_MotorNO)
    TextView acUniquenessEngineNOMotorNO;
    @BindView(R.id.ac_uniqueness_VIN)
    TextView acUniquenessVIN;
    @BindView(R.id.ac_uniqueness_BodyColor)
    TextView acUniquenessBodyColor;


    private String Login_name = "", login_IDNumber;//当前登录的检测员的名字
    private CarsInforModel carsInforModel;
    private WaiJainDataModel waiJainDataModel = new WaiJainDataModel();//外检上传数据model

    String upload_code_str = "", upload_code_str_500 = "", upload_code_str_names = "";
    List<MyChoiceModel> myChoiceModelList_waijian = new ArrayList<>();//Code2选择的列表
    boolean is_500 = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_uniqueness);
        ButterKnife.bind(this);
        setBackBtn();
        setTopTitle("车辆唯一性检查");

        instances = this;
        BaseApplication.BaseApplication_buHeGeModel3List = new ArrayList<>();
        acUniCountupViewTest3.setTag("test2");
        long time1 = (long) 1000;
        acUniCountupViewTest3.start(time1);

        String logStrf = "\n" + "onCreate-----车辆唯一性检查-----" + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrf.getBytes());
        acUniquenessDesc.setCursorVisible(false);
        carsInforModel = (CarsInforModel) getIntent().getSerializableExtra("model_CarsInforModel");
        login_IDNumber = getIntent().getExtras().getString("login_IDNumber", "");
        Login_name = getIntent().getExtras().getString("login_w_name", "");
        line = getIntent().getExtras().getString("Car_Line", "");
        beizhu = getIntent().getExtras().getString("EngineNOFlag", "");
        UtilsLog.e("车辆唯一性检查--carsInforModel====" + carsInforModel.toString());
        UtilsLog.e("车辆唯一性检查--login_IDNumber====" + login_IDNumber);
        UtilsLog.e("车辆唯一性检查--Login_name====" + Login_name);
        UtilsLog.e("车辆唯一性检查--line====" + line);
        UtilsLog.e("车辆唯一性检查-EngineNOFlag==" + beizhu);
        String memoLog = "memoLog------车辆唯一性检查-EngineNOFlag==" + beizhu;
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, memoLog.getBytes());

        acUniquenessLine.setText(line);
        if (carsInforModel != null) {
            //车牌号码
            if (!TextUtils.isEmpty(carsInforModel.getPlateRegion()) &&
                    !TextUtils.isEmpty(carsInforModel.getPlateNO())) {
                acUniquenessOnlineCarno.setText(carsInforModel.getPlateRegion() +
                        carsInforModel.getPlateNO());
            }
            //检验次数```````
            if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getTimes()))) {
                acUniquenessOnlineTimes.setText(carsInforModel.getTimes() + "次");
            }
            //SN
            if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getSN()))) {
                acUniquenessSN.setText(carsInforModel.getSN());
            }
            //车辆品牌和型号
            if(!TextUtils.isEmpty(String.valueOf(carsInforModel.getBrand())) || !TextUtils.isEmpty(String.valueOf(carsInforModel.getCarModel()))){
                acUniquenessBrandCarModel.setText(carsInforModel.getBrand() + carsInforModel.getCarModel());
            }
            //发动机/驱动电机号码
            if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getEngineNO())) || !TextUtils.isEmpty(String.valueOf(carsInforModel.getMotorNO()))){
                acUniquenessEngineNOMotorNO.setText(carsInforModel.getEngineNO() + "/" + carsInforModel.getMotorNO());
            }
            //VIN
            if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getVIN()))){
                acUniquenessVIN.setText(carsInforModel.getVIN());
            }
            //车身颜色
            if (!TextUtils.isEmpty(String.valueOf(carsInforModel.getBodyColor()))){
                acUniquenessBodyColor.setText(VehicleCheckUtils.CarColorsFilter(carsInforModel
                        .getBodyColor()));
            }
            //注册登记用车
            if (!TextUtils.isEmpty(carsInforModel.getDetectionCategory())) {
                if (carsInforModel.getDetectionCategory().equals("00")) {
                    //3:1   2:0  新车
                    acUniquenessHaopaiHaomaFenlei.setText("未检");
                    acUniquenessCheliangPinpaiXinghao.setText("合格");
                } else {
                    //3:0   2:1
                    acUniquenessHaopaiHaomaFenlei.setText("合格");
                    acUniquenessCheliangPinpaiXinghao.setText("未检");
                }
            }
        }

        if (myChoiceModelList != null && myChoiceModelList.size() > 0) {
            myChoiceModelList.clear();
        }
        List<Item_2Model> Item_2Model_list = new ArrayList<>();//Code2去重后的所有数据
        Item_2Model item_2 = null;
        for (int i = 0; i < BaseApplication.checkItemModelList.size(); i++) {
            item_2 = new Item_2Model();
            item_2.setID(BaseApplication.checkItemModelList.get(i).getID());
            item_2.setCode1(BaseApplication.checkItemModelList.get(i).getCode1());
            item_2.setCode2(BaseApplication.checkItemModelList.get(i).getCode2());
            item_2.setName2(BaseApplication.checkItemModelList.get(i).getName2());
            item_2.setName3(BaseApplication.checkItemModelList.get(i).getName3());
            Item_2Model_list.add(item_2);
        }
        for (int k = 0; k < Item_2Model_list.size() - 1; k++) {
            for (int j = Item_2Model_list.size() - 1; j > k; j--) {
                if (Item_2Model_list.get(j).getCode2().equals(Item_2Model_list.get(k).getCode2())) {
                    Item_2Model_list.remove(j);
                }
            }
        }
        if (IsFirst) {
            for (int i = 0; i < Item_2Model_list.size(); i++) {
                // UtilsLog.e("Item_2Model_list=11=" + Item_2Model_list.get(i).toString());
                MyChoiceModel model = new MyChoiceModel();
                model.setCode2(Item_2Model_list.get(i).getCode2());
                model.setChecked(true);
                model.setName2(Item_2Model_list.get(i).getName2());
                model.setName3(Item_2Model_list.get(i).getName3());
                model.setCode_key("Code2-" + Item_2Model_list.get(i).getCode2());
                model.setCode_values("0");
                myChoiceModelList.add(model);
            }
//            for (int i = 0; i < myChoiceModelList.size(); i++) {
//                UtilsLog.e("myChoiceModelList=11=" + myChoiceModelList.get(i).toString());
//            }
            getMyCarItems();
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        OkGo.getInstance().cancelTag(this);
        String logStrf = "\n" + "onDestroy-----车辆唯一性检查-----" + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrf.getBytes());
        instances = null;
        acUniCountupViewTest3.stop();
    }

    @OnClick({R.id.ac_uniqueness_line, R.id.ac_uniqueness_haopai_haoma_fenlei,
            R.id.ac_uniqueness_cheliang_pinpai_xinghao, R.id.ac_uniqueness_cheliang_shibie_daihao,
            R.id.ac_uniqueness_fadongji_haoma, R.id.ac_uniqueness_cheliang_yanse_cheliang_waixing,
            R.id.ac_uniqueness_desc, R.id.ac_uniqueness_btn_start, R.id.ac_uniqueness_btn_buhege,
            R.id.ac_uniqueness_btn_end, R.id.ac_uniqueness_btn_paizhao_vin,
            R.id.ac_uniqueness_tv_beizhu_more})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.ac_uniqueness_tv_beizhu_more:
                showMyDialog(more_str, R.id.ac_uniqueness_tv_beizhu_more);
                break;
            case R.id.ac_uniqueness_btn_buhege:
                //不合格项目录入
                String logStr2 = "\n" + "联网查询--外检不合格项目按钮点击" + "\n";
                PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr2.getBytes());
                getMyCarItems();
                Handler handler = new Handler();
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        Intent intent_2 = new Intent(instances, WaiJianResultActivity.class);
                        intent_2.putExtra("WaiJianPhotoActivity_CarsInforModel", carsInforModel);
                        startActivityForResult(intent_2, 500);
                    }
                }, 400);//后执行Runnable中的run方法
                break;
            case R.id.ac_uniqueness_btn_paizhao_vin:
                //vin拍照
                Intent intent2 = new Intent(this, UniquenessPhotoActivity.class);
                intent2.putExtra("model_CarsInforModel", carsInforModel);
                intent2.putExtra("check_mode", 0);
                intent2.putExtra("Login_name", Login_name);
                intent2.putExtra("login_IDNumber", login_IDNumber);
                intent2.putExtra("Line", acUniquenessLine.getText().toString().trim());
                startActivity(intent2);
                break;
            case R.id.ac_uniqueness_desc:
                //描述
                acUniquenessDesc.setCursorVisible(true);
                break;
//            case R.id.ac_uniqueness_line:
//                //检测线号
//                showMyDialog(line_str, R.id.ac_uniqueness_line);
//                break;
            case R.id.ac_uniqueness_haopai_haoma_fenlei:
                //号牌号码和分类 0-未检，1-合格，2-不合格，下同
                showMyDialog(he_ge_str, R.id.ac_uniqueness_haopai_haoma_fenlei);
                break;
            case R.id.ac_uniqueness_cheliang_pinpai_xinghao:
                //车辆品牌和型号
                showMyDialog(he_ge_str, R.id.ac_uniqueness_cheliang_pinpai_xinghao);
                break;
            case R.id.ac_uniqueness_cheliang_shibie_daihao:
                //车辆识别代号
                showMyDialog(he_ge_str, R.id.ac_uniqueness_cheliang_shibie_daihao);
                break;
            case R.id.ac_uniqueness_fadongji_haoma:
                //发动机号码
                showMyDialog(he_ge_str, R.id.ac_uniqueness_fadongji_haoma);
                break;
            case R.id.ac_uniqueness_cheliang_yanse_cheliang_waixing:
                //车辆颜色和车辆外形
                showMyDialog(he_ge_str, R.id.ac_uniqueness_cheliang_yanse_cheliang_waixing);
                break;
            case R.id.ac_uniqueness_btn_start:
                //项目开始
                line = acUniquenessLine.getText().toString().trim();
                desc = acUniquenessDesc.getText().toString().trim();
                if(SharedPreferencesUtils.getTianJinVersion(instances)){
                    TianJin_warning();
                    new Handler().postDelayed(()->{
                        getDataWaiJainStart();
                    },1500);
                }else{
                    getDataWaiJainStart();
                }
//                Intent intent = new Intent(this, UniquenessPhotoActivity.class);
//                intent.putExtra("line", line);
//                intent.putExtra("desc", desc);
//                startActivity(intent);
                break;
            case R.id.ac_uniqueness_btn_end:
                //项目 end
                line = acUniquenessLine.getText().toString().trim();
                desc = acUniquenessDesc.getText().toString().trim();
//                beizhu = acUniquenessBeizhu.getText().toString().trim();
                //上传平台的数据--项目结束
//                if (SharedPreferencesUtils.getHaErBinVersion(instances)){
//                    // 哈尔滨地区要限值时间120秒
//                    if (acUniCountupViewTest3.getMinute() >= 2){
//                        initJsonDataToPlateform();
//                    } else {
//                        Toast.makeText(instances,"未达120s，项目无法结束",Toast.LENGTH_LONG).show();
//                    }
//                }else {
//                    //其他地区暂时不做限值
//                    initJsonDataToPlateform();
//                }
                initJsonDataToPlateform();
                break;
        }
    }

    private String[] more_str = new String[]{"无", "发动机标识缺失且打刻号码不易见,无法拍摄","发动机号已查验核实但无法拍摄"};
    private String[] line_str = new String[]{"1", "2", "3", "4", "5", "6"};
    //    private String[] line_str = new String[]{"01", "02", "03", "04", "05", "06"};
    private String[] he_ge_str = new String[]{"未检", "合格", "不合格"};

    private void showMyDialog(String[] str, final int id) {
//        BottomMenu bottomMenu= BottomMenu().build(this);
        BottomMenu.show(this, str, new OnMenuItemClickListener() {
            @Override
            public void onClick(String text, int index) {
                //返回参数 text 即菜单名称，index 即菜单索引
                UtilsLog.e("车辆唯一性---showMyDialog==" + text + "===" + index);
                switch (id) {
                    case R.id.ac_uniqueness_line:
                        // 线号
                        acUniquenessLine.setText(text);
                        break;
                    case R.id.ac_uniqueness_haopai_haoma_fenlei:
                        //号牌号码和分类 0-未检，1-合格，2-不合格，下同
                        acUniquenessHaopaiHaomaFenlei.setText(text);
                        break;
                    case R.id.ac_uniqueness_cheliang_pinpai_xinghao:
                        //车辆品牌和型号
                        acUniquenessCheliangPinpaiXinghao.setText(text);
                        break;
                    case R.id.ac_uniqueness_cheliang_shibie_daihao:
                        //车辆识别代号
                        acUniquenessCheliangShibieDaihao.setText(text);
                        break;
                    case R.id.ac_uniqueness_fadongji_haoma:
                        //发动机号码
                        acUniquenessFadongjiHaoma.setText(text);
                        break;
                    case R.id.ac_uniqueness_cheliang_yanse_cheliang_waixing:
                        //车辆颜色和车辆外形
                        acUniquenessCheliangYanseCheliangWaixing.setText(text);
                        break;
                    case R.id.ac_uniqueness_tv_beizhu_more:
                        acUniquenessBeizhu.setText(text);
                        break;
                }
            }
        }).setMenuTextInfo(new TextInfo().setBold(true).setFontColor(Color.BLACK).setGravity(Gravity.CENTER));
    }

    //item检测开始
    private void getDataWaiJainStart() {
        CarItemStartModel carItemStartModel = new CarItemStartModel();
        carItemStartModel.setPlatformSN(carsInforModel.getPlatformSN());
        carItemStartModel.setPlateType(carsInforModel.getPlateType());
//        carItemStartModel.setPlateNO(carsInforModel.getPlateNO());
        carItemStartModel.setPlateNO(carsInforModel.getPlateRegion() + carsInforModel.getPlateNO());
//        data.get(position).getPlateRegion() + data.get(position).getPlateNO()
        carItemStartModel.setVIN(carsInforModel.getVIN());
        carItemStartModel.setDetectionID(String.valueOf(carsInforModel.getID()));
        carItemStartModel.setLine(line);
        carItemStartModel.setTest_times(carsInforModel.getTimes());
        carItemStartModel.setDetectionDevID(SharedPreferencesUtils.getIMEI(instances));
        carItemStartModel.setItemCode(Item_Code);
        carItemStartModel.setLeadTruck(Login_name);
        item_start_time = "";
        item_start_time = DateUtil.currentTime2();
//        carItemStartModel.setDetectionItemStartDate(DateUtil.currentTime2());
        carItemStartModel.setDetectionItemStartDate(item_start_time);
        Gson gson = new Gson();
        String jsonStr = gson.toJson(carItemStartModel);

//        String upjson_url = "{[" + jsonStr.substring(1, jsonStr.length() - 1) + "]}";
//        String upjson_url = "{" + jsonStr.substring(1, jsonStr.length() - 1) + "}";

        String logStr = "\n" + "车辆唯一性检查---项目开始-json" + "\n" +
                "json::" + jsonStr + "\n" +
                "URL::" + SharedPreferencesUtils.getIP(instances) + ITEM_START;
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        UtilsLog.e("车辆唯一性检查---jsonStr==" + jsonStr);
        UtilsLog.e("车辆唯一性检查---url==" + SharedPreferencesUtils.getIP(this) + ITEM_START);
        OkGo.<String>post(SharedPreferencesUtils.getIP(this) + ITEM_START)
                .tag(this)
                .upJson(jsonStr)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(instances, "加载中...");
                        WaitDialog.show(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        WaitDialog.dismiss();
                        String result = response.body().trim();
                        UtilsLog.e("车辆唯一性检查--result==" + result);
                        UtilsLog.e("车辆唯一性检查--result=22=" + result.substring(1, result.length() -
                                1));
                        String logStr = "\n" + "车辆唯一性检查---项目开始---请求成功" + "\n" +
                                "result::" + response.body() + "\n" +
                                "URL::" + SharedPreferencesUtils.getIP(instances) + ITEM_START;
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
//                        CommonUtils.hideLoadingDialog(instances);
                        String str = result.substring(1, result.length() - 1);
                        if ("ok".equalsIgnoreCase(str)) {
//                            long time1 = (long) 1000;
//                            acUniCountupViewTest3.start(time1);
//                        finish();
//                            Toast.makeText(instances, "联网项目开始成功", Toast.LENGTH_LONG)
//                                    .show();
                            TipDialog.show(instances, "车辆唯一性检查开始成功", TipDialog.TYPE.SUCCESS);
                        } else {
                            MessageDialog.show(instances, "提示", "车辆唯一性检查开始失败，请重试", "确定");
                        }
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        WaitDialog.dismiss();
                        String logStr2 = "\n" + "车辆唯一性检查---项目开始-onError" + "\n" +
                                "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr2.getBytes());
                        UtilsLog.e("联网查询-onError==" + response.body());
//                        CommonUtils.hideLoadingDialog(instances);
                        MessageDialog.show(instances, "提示", "车辆唯一性检查开始网络异常，请重试", "确定");
                    }
                });
    }

    //外检检测结束
    private void getDataWaiJainEnd() {
        CarItemEndModel carItemStartModel = new CarItemEndModel();
        carItemStartModel.setPlatformSN(carsInforModel.getPlatformSN());
        carItemStartModel.setPlateType(carsInforModel.getPlateType());
//        carItemStartModel.setPlateNO(carsInforModel.getPlateNO());
        carItemStartModel.setPlateNO(carsInforModel.getPlateRegion() + carsInforModel.getPlateNO());
        carItemStartModel.setDetection_ID(String.valueOf(carsInforModel.getID()));
        carItemStartModel.setVIN(carsInforModel.getVIN());
        carItemStartModel.setLine(line);
        carItemStartModel.setTest_times(carsInforModel.getTimes());
        carItemStartModel.setDetectionDevID(SharedPreferencesUtils.getIMEI(instances));
        carItemStartModel.setItemCode(Item_Code);
        item_end_time = "";
        item_end_time = DateUtil.currentTime2();
        carItemStartModel.setDetectionItemEndDate(item_end_time);
//        carItemStartModel.setDetectionItemEndDate(endTime);
        Gson gson = new Gson();
        String jsonStr = gson.toJson(carItemStartModel);
//        String upjson_url = "{[" + jsonStr.substring(1, jsonStr.length() - 1) + "]}";
//        getDataWaiJainEnd_upjson_url = "{" + jsonStr.substring(1, jsonStr.length() - 1) + "}";
        String logStr = "\n" + "车辆唯一性检查--项目结束---json" + "\n" +
                "json::" + jsonStr + "\n" +
                "URL::" + SharedPreferencesUtils.getIP(instances) + ITEM_END;
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        UtilsLog.e("getDataWaiJainEnd---jsonStr==" + jsonStr);
        UtilsLog.e("getDataWaiJainEnd---url==" + SharedPreferencesUtils.getIP(this) + ITEM_END);
        OkGo.<String>post(SharedPreferencesUtils.getIP(this) + ITEM_END).tag(this)
                .upJson(jsonStr)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body();
                        UtilsLog.e("getDataWaiJainEnd-result==" + result);
                        CommonUtils.hideLoadingDialog(instances);
                        String newResult = result.substring(1, result.length() - 1).replaceAll("\\\\", "");
                        UtilsLog.e("getDataWaiJainEnd-newResult==" + newResult);
                        String logStr = "\n" + "车辆唯一性检查--项目结束--请求成功" + "\n" + "URL::" +
                                SharedPreferencesUtils.getIP(instances) + "" +
                                ITEM_END + "\n" + "result::" + result;
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        if ("ok".equalsIgnoreCase(newResult)) {
                            EndAllItem(String.valueOf(carsInforModel.getID()));
//                            TipDialog.show(instances, "车辆唯一性检查结束成功", TipDialog.TYPE.SUCCESS);
//                            Handler handler = new Handler();
//                            handler.postDelayed(new Runnable() {
//                                @Override
//                                public void run() {
////                                    finish();
//                                    Intent intent = new Intent();
//                                    intent.putExtra("nq", 1);
//                                    instances.setResult(102, intent);
//                                    instances.finish();
//                                }
//                            }, 1200);//后执行Runnable中的run方法
                        } else {
                            MessageDialog.show(instances, "提示", "车辆唯一性检查结束失败，请重试", "确定");
                        }
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        UtilsLog.e("getDataWaiJainEnd-onError==" + response.body());
                        String logStr = "\n" + "车辆唯一性检查--项目结束--onError-失败" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(instances) +
                                ITEM_END + "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        CommonUtils.hideLoadingDialog(instances);
                        MessageDialog.show(instances, "提示", "车辆唯一性检查网络异常，请重试", "确定");
                    }
                });
    }

    void initJsonDataToPlateform() {
        WaitDialog.show(instances, "加载中...");
        waiJainDataModel.setReplaceEngineType(carsInforModel.getReplaceEngineType());
        waiJainDataModel.setReplaceEngineNO(carsInforModel.getReplaceEngineNO());
        waiJainDataModel.setUCResultNote(desc);
        waiJainDataModel.setDetection_ID(String.valueOf(carsInforModel.getID()));
        waiJainDataModel.setGUID(carsInforModel.getGUID());
        waiJainDataModel.setDetectionDevID(SharedPreferencesUtils.getIMEI(instances));
        waiJainDataModel.setBrakeForce(carsInforModel.getBrakeForce());
        waiJainDataModel.setPlateNO(carsInforModel.getPlateRegion() + carsInforModel.getPlateNO());
        waiJainDataModel.setAirAdmission(carsInforModel.getAirAdmission());
        try {
            String name = URLDecoder.decode(Login_name, "UTF-8");
            waiJainDataModel.setAppearanceInspector(name);//检测员名字，汉字
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        waiJainDataModel.setLeadTruck(Login_name);
        waiJainDataModel.setAppearanceNo(login_IDNumber);
        waiJainDataModel.setApprovedLoad(carsInforModel.getApprovedLoad());
        waiJainDataModel.setArea(carsInforModel.getArea());
        waiJainDataModel.setBodyColor(carsInforModel.getBodyColor());
        waiJainDataModel.setBrand(carsInforModel.getBrand());
        waiJainDataModel.setCarBodyType(carsInforModel.getCarBodyType());
        waiJainDataModel.setCarID(carsInforModel.getCarID());
        waiJainDataModel.setCarModel(carsInforModel.getCarModel());
        waiJainDataModel.setCarTypeLevel(carsInforModel.getCarTypeLevel());
        waiJainDataModel.setCategory(carsInforModel.getCategory());
        waiJainDataModel.setCentralAxle(carsInforModel.getCentralAxle());
        waiJainDataModel.setCode(carsInforModel.getCode());
        waiJainDataModel.setCombCarNO(carsInforModel.getCombCarNO());
        waiJainDataModel.setCurbWeight(carsInforModel.getCurbWeight());
        waiJainDataModel.setDetectDate(carsInforModel.getDetectDate());
        waiJainDataModel.setDetectionCategory(carsInforModel.getDetectionCategory());
        waiJainDataModel.setDetectionStatus(carsInforModel.getDetectionStatus());
        waiJainDataModel.setDisplacement(carsInforModel.getDisplacement());
        waiJainDataModel.setDriveAxle(carsInforModel.getDriveAxle());
        waiJainDataModel.setDriverAxleWeight(carsInforModel.getDriverAxleWeight());
        waiJainDataModel.setDriverTypeName(carsInforModel.getDriverTypeName());
        waiJainDataModel.setDriverType(carsInforModel.getDriverType());
        waiJainDataModel.setPlateType(carsInforModel.getPlateType());
        waiJainDataModel.setItemcode(Item_Code);
        waiJainDataModel.setLine(line);
        waiJainDataModel.setMainAxis(carsInforModel.getMainAxis());
        waiJainDataModel.setParkingAxle(carsInforModel.getParkingAxle());
        waiJainDataModel.setEngineNO(carsInforModel.getEngineNO());
        waiJainDataModel.setFuelType(carsInforModel.getFuelType());
        waiJainDataModel.setPlateTypeName(carsInforModel.getPlateTypeName());
        waiJainDataModel.setPlatformSN(carsInforModel.getPlatformSN());
        waiJainDataModel.setQueueID(carsInforModel.getQueueID());
        waiJainDataModel.setSN(carsInforModel.getSN());
        waiJainDataModel.setStatus(carsInforModel.getStatus());
        waiJainDataModel.setTest_times(carsInforModel.getTimes());
        waiJainDataModel.setType(carsInforModel.getType());
        waiJainDataModel.setVIN(carsInforModel.getVIN());
        waiJainDataModel.setDataType(Item_Code);
        waiJainDataModel.setOwner(carsInforModel.getOwner());
        waiJainDataModel.setTelephone(carsInforModel.getTelephone());
        waiJainDataModel.setAddress(carsInforModel.getAddress());
        waiJainDataModel.setMemo(beizhu);
        uploadPlatformData(waiJainDataModel);
    }

    //外检上传平台数据
    String upjson_url;

    private void uploadPlatformData(WaiJainDataModel waiJainDataModel) {
        String memoLog2 = "memoLog2------车辆唯一性检查-EngineNOFlag==" + beizhu;
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, memoLog2.getBytes());
        Gson gson = new Gson();
        String jsonStr = gson.toJson(waiJainDataModel);
//        upjson_url = "[{" + jsonStr.substring(1, jsonStr.length() - 1) + "," +
//                appendCode2AndValues() + "}]";
//        upjson_url = "[{" + jsonStr.substring(1, jsonStr.length() - 1) + "," +
//                codeStr2() + "}]";
        if (is_500) {
            upjson_url = "[{" + jsonStr.substring(1, jsonStr.length() - 1) + "," +
                    upload_code_str_500 + "}]";
        } else {
            upjson_url = "[{" + jsonStr.substring(1, jsonStr.length() - 1) + "," +
                    upload_code_str + "}]";
        }
        UtilsLog.e("车辆唯一性检查--上传平台数据---jsonStr==" + upjson_url);
        UtilsLog.e("车辆唯一性检查--上传平台数据---url==" + SharedPreferencesUtils.getIP(this) + PLAT_FORM_DATA);
        String logStr = "\n" + "车辆唯一性检查--上传平台数据---json" + "\n" +
                "json::" + upjson_url + "\n" +
                "URL::" + SharedPreferencesUtils.getIP(instances) + PLAT_FORM_DATA;
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        OkGo.<String>post(SharedPreferencesUtils.getIP(this) + PLAT_FORM_DATA).tag(this)
                .upJson(upjson_url)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body();
                        UtilsLog.e("车辆唯一性检查--上传平台数据--result==" + result);
                        String newResult = result.substring(1, result.length() - 1).replaceAll("\\\\", "");
                        UtilsLog.e("车辆唯一性检查--上传平台数据--newResult==" + newResult);
                        String logStr = "\n" + "车辆唯一性检查--上传平台数据---请求成功" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(instances) +
                                PLAT_FORM_DATA + "\n" + "JSON::" + upjson_url +
                                "\n" + "result::" + result;
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        if ("ok".equalsIgnoreCase(newResult)) {
                            Handler handler = new Handler();
                            handler.postDelayed(new Runnable() {
                                @Override
                                public void run() {
                                    uploadBuHeGeData();
//                                    updateCarStatusInfor();
                                }
                            }, 100);//后执行Runnable中的run方法
                        } else {
                            MessageDialog.show(instances, "提示", "上传平台数据失败，请重试", "确定");
                        }
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        UtilsLog.e("联网查询--上传平台数据-onError==" + response.body());
                        String logStr = "\n" + "车辆唯一性检查--上传平台数据--onError-失败" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(instances) +
                                PLAT_FORM_DATA + "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        CommonUtils.hideLoadingDialog(instances);
                        MessageDialog.show(instances, "提示", "上传平台数据网络异常，请重试", "确定");
                    }
                });
    }

    private String getHeGeStatement(String str) {
        String result = "1";
        if (str.equals("合格")) {
            result = "1";
        } else if (str.equals("不合格")) {
            result = "2";
        } else if (str.equals("未检")) {
            result = "0";
        }
        return result;
    }

    //拼装json  --Code2
    private String appendCode2AndValues() {
        String Code2JsonStr = "";
        String result = "";
        if (myChoiceModelList != null && myChoiceModelList.size() > 0) {
            for (int i = 0; i < myChoiceModelList.size(); i++) {
                //号牌号码和分类
                String str2 = acUniquenessHaopaiHaomaFenlei.getText().toString().trim();
                //车辆品牌和型号
                String str3 = acUniquenessCheliangPinpaiXinghao.getText().toString().trim();
                //车辆识别代号
                String str4 = acUniquenessCheliangShibieDaihao.getText().toString().trim();
                //发动机号码
                String str5 = acUniquenessFadongjiHaoma.getText().toString().trim();
                //车辆颜色和车辆外形
                String str6 = acUniquenessCheliangYanseCheliangWaixing.getText().toString().trim();

                if (myChoiceModelList.get(i).getCode_key().equals("Code2-2")) {
                    myChoiceModelList.get(i).setCode_values(getHeGeStatement(str2));
                }

                if (myChoiceModelList.get(i).getCode_key().equals("Code2-3")) {
                    myChoiceModelList.get(i).setCode_values(getHeGeStatement(str3));
                }

                if (myChoiceModelList.get(i).getCode_key().equals("Code2-4")) {
                    myChoiceModelList.get(i).setCode_values(getHeGeStatement(str4));
                }
                if (myChoiceModelList.get(i).getCode_key().equals("Code2-5")) {
                    myChoiceModelList.get(i).setCode_values(getHeGeStatement(str5));
                }
                if (myChoiceModelList.get(i).getCode_key().equals("Code2-6")) {
                    myChoiceModelList.get(i).setCode_values(getHeGeStatement(str6));
                }
                Code2JsonStr = Code2JsonStr + "\"" + myChoiceModelList.get(i).getCode_key() + "\""
                        + ":" + "\"" + myChoiceModelList.get(i).getCode_values() + "\"" + ",";
            }
//            UtilsLog.e("Code2JsonStr==" + Code2JsonStr);
            UtilsLog.e("车辆唯一性检查--==Code2JsonStr=22=" + Code2JsonStr.substring(0, Code2JsonStr.length() - 1));
        }
        if (Code2JsonStr.length() > 0) {
            result = Code2JsonStr.substring(0, Code2JsonStr.length() - 1);
        }
        String logStr = "\n" + "车辆唯一性检查--appendCode2AndValues---json" + "\n" +
                "json::" + result + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        UtilsLog.e("车辆唯一性检查--==appendCode2AndValues==" + result);
        return result;
    }

    public String codeStr2() {
        String result = "";
        //号牌号码和分类
        String str2 = acUniquenessHaopaiHaomaFenlei.getText().toString().trim();
        //车辆品牌和型号
        String str3 = acUniquenessCheliangPinpaiXinghao.getText().toString().trim();
        //车辆识别代号
        String str4 = acUniquenessCheliangShibieDaihao.getText().toString().trim();
        //发动机号码
        String str5 = acUniquenessFadongjiHaoma.getText().toString().trim();
        //车辆颜色和车辆外形
        String str6 = acUniquenessCheliangYanseCheliangWaixing.getText().toString().trim();
        result = "\"Code2-2\":" + getHeGeStatement(str2) + "," + "\"Code2-3\":" + getHeGeStatement(str3) + ","
                + "\"Code2-4\":" + getHeGeStatement(str4) + "," + "\"Code2-5\":" + getHeGeStatement(str5) + "," +
                "\"Code2-6\":" + getHeGeStatement(str6);
        return result;
    }

    //获取需要检测的人工检验项目接口
    private void getMyCarItems() {
        ItemsModel model = new ItemsModel();
        model.setCarType(carsInforModel.getType());
        model.setDetectCategroy(carsInforModel.getDetectionCategory());
        model.setPassengerNb(carsInforModel.getApprovedLoad());
        model.setPlateType(carsInforModel.getPlateType());
        model.setVehicleID(String.valueOf(carsInforModel.getVehicleID()));

        String registerTime = carsInforModel.getRegisteDate();
        String str = registerTime.substring(6, registerTime.length() - 2).trim();
        String registerdate = DateUtil.getDateTimeFromMillisecond(Long.parseLong(str));
        model.setRegisteDate(registerdate);

        Gson gson = new Gson();
        String json_str = gson.toJson(model);
        UtilsLog.e("车辆唯一性检查---getMyCarItems---json_str==" + json_str);
        String url = "";
        url = GET_MY_ITEM_38900;
        UtilsLog.e("getMyCarItems---url==" + SharedPreferencesUtils.getIP(this) + url);

        String logStr = "\n" + "车辆唯一性检查--外检--获取需要检测的人工检验项目接口--请求" +
                "\n" + "URL::" + SharedPreferencesUtils.getIP(instances) +
                url + "\n" + "JSON::" + json_str + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        OkGo.<String>post(SharedPreferencesUtils.getIP(this) + url).tag(this)
                .upJson(json_str)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body();
                        String newResult = result.substring(1, result.length() - 1).replaceAll("\\\\", "");
                        UtilsLog.e("getMyCarItems-newResult==" + newResult);
                        String logStrf = "\n" + "车辆唯一性检查--外检--获取需要检测的人工检验项目接口--请求成功" +
                                "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrf.getBytes());

                        if (!TextUtils.isEmpty(newResult) && !"[[]]".equals(newResult) && !"[{}]".equals
                                (newResult) && !"[]".equals(result)) {
                            List<CheckItemModel> DiPanDongTai_checkItemlList = new ArrayList<>();
                            mycar_checkItemlList = new ArrayList<CheckItemModel>();
                            myChoiceModelList_waijian = new ArrayList<>();
                            DiPanDongTai_checkItemlList = JsonUtil.stringToArray(newResult,
                                    CheckItemModel[].class);
                            if (DiPanDongTai_checkItemlList != null && DiPanDongTai_checkItemlList.size() > 0) {
                                List<Item_2Model> Item_2Model_list = new ArrayList<>();//Code2去重后的所有数据
                                Item_2Model item_2 = null;
                                for (int i = 0; i < DiPanDongTai_checkItemlList.size(); i++) {
//                                    UtilsLog.e("getMyCarItems-DiPanDongTai_checkItemlList==" +
//                                            DiPanDongTai_checkItemlList.get(i).toString());
                                    if (DiPanDongTai_checkItemlList.get(i).getCode1().equals("2")) {
                                        mycar_checkItemlList.add(DiPanDongTai_checkItemlList.get(i));
                                        item_2 = new Item_2Model();
                                        item_2.setID(DiPanDongTai_checkItemlList.get(i).getID());
                                        item_2.setCode1(DiPanDongTai_checkItemlList.get(i).getCode1());
                                        item_2.setCode2(DiPanDongTai_checkItemlList.get(i).getCode2());
                                        item_2.setName2(DiPanDongTai_checkItemlList.get(i).getName2());
                                        item_2.setFlag(DiPanDongTai_checkItemlList.get(i).getFlag());
                                        Item_2Model_list.add(item_2);
                                    }
                                }
                                UtilsLog.e("Item_2Model_list=22=myChoiceMItem_2Model_listodelList==111111=" + Item_2Model_list.toString());
                                for (int k = 0; k < Item_2Model_list.size() - 1; k++) {
                                    for (int j = Item_2Model_list.size() - 1; j > k; j--) {
                                        if (Item_2Model_list.get(j).getCode2().equals(Item_2Model_list.get(k)
                                                .getCode2())) {
                                            Item_2Model_list.remove(j);
                                        }
                                    }
                                }

                                if (Item_2Model_list != null && Item_2Model_list.size() > 0) {
                                    setDataModel(Item_2Model_list);
                                } else {
                                    String logStrfw = "\n" + "车辆唯一性检查-外检--获取需要检测的人工检验项目接口--Item_2Model_list==null" + "\n";
                                    PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrfw.getBytes());
                                }
                                for (int i = 0; i < Item_2Model_list.size(); i++) {
                                    MyChoiceModel model = new MyChoiceModel();
                                    model.setCode2(Item_2Model_list.get(i).getCode2());
                                    model.setChecked(true);
                                    model.setName2(Item_2Model_list.get(i).getName2());
                                    model.setCode_key("Code2-" + Item_2Model_list.get(i).getCode2());
                                    model.setCode_values(Item_2Model_list.get(i).getFlag());
                                    myChoiceModelList_waijian.add(model);
                                }
                                if (myChoiceModelList != null && myChoiceModelList.size() > 0) {
                                    for (int i = 0; i < myChoiceModelList.size(); i++) {
//                                        UtilsLog.e("Code2JsonStr=22=myChoiceModelList==111111=" + myChoiceModelList.get(i).toString());
                                        String Code2 = myChoiceModelList.get(i).getCode2().toString().trim();
                                        for (int j = 0; j < Item_2Model_list.size(); j++) {
                                            String code2_my = Item_2Model_list.get(j).getCode2().toString()
                                                    .trim();
                                            if (Code2.equals(code2_my)) {
                                                myChoiceModelList.get(i).setCode_values(Item_2Model_list.get(j).getFlag());
                                            }
                                        }
                                    }
                                } else {
                                    UtilsLog.e("myChoiceModelList=================");
                                }

                                if (myChoiceModelList_waijian != null && myChoiceModelList_waijian.size() > 0) {
                                    upload_code_str = "";
                                    for (int i = 0; i < myChoiceModelList_waijian.size(); i++) {
                                        upload_code_str = upload_code_str + "\"" + myChoiceModelList_waijian.get(i).getCode_key() + "\""
                                                + ":" + "\"" + myChoiceModelList_waijian.get(i).getCode_values() + "\"" + ",";
                                    }
                                    if (upload_code_str.length() > 0) {
                                        upload_code_str = upload_code_str.substring(0, upload_code_str.length() - 1);
                                    }
                                    String logStrfw = "\n" + "车辆唯一性检查--外检--获取需要检测的人工检验项目接口--upload_code_str" +
                                            "\n" + "upload_code_str::" + upload_code_str;
                                    PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrfw.getBytes());
                                    UtilsLog.e("upload_code_str========" + upload_code_str);
                                } else {
                                    UtilsLog.e("myChoiceModelList_waijian=================");
                                }
                            } else {
                                UtilsLog.e("getMyCarItems-Result==没有获取到当前车辆检测到的项目");
                            }
//
//                            Intent intent_2 = new Intent(instances, BuWaiJianResultActivity.class);
//                            intent_2.putExtra("WaiJianPhotoActivity_CarsInforModel", carsInforModel);
//                            startActivityForResult(intent_2, 500);

                        } else {
                            UtilsLog.e("getGET_ALL_ITEMList-result==" + "没有数据");
                        }
                        CommonUtils.hideLoadingDialog(instances);
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        UtilsLog.e("getMyCarItems-onError==" + response.body());
                        CommonUtils.hideLoadingDialog(instances);
                        String logStrf = "\n" + "车辆唯一性检查--外检--获取需要检测的人工检验项目接口--请求失败--error" +
                                "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrf.getBytes());
                    }
                });
    }

    String jsonStr22;

    public void updateCarStatusInfor() {
        UpdateCarStatusModel model = new UpdateCarStatusModel();
        model.setType(0);
        model.setAppearanceInspector(Login_name);
        model.setQueueID(String.valueOf(carsInforModel.getID()));
        model.setUCStatus("1");
        Gson gson = new Gson();
        jsonStr22 = gson.toJson(model);
        String logStr = "\n" + "车辆唯一性检查--更新车辆状态---json--" +
                "\n" + "URL::" + SharedPreferencesUtils.getIP(instances) +
                UPDATE_CAR_STATUS + "\n" + "JSON::" + jsonStr22 + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        UtilsLog.e("updateCarStatusInfor---jsonStr==" + jsonStr22);
        UtilsLog.e("updateCarStatusInfor---url==" + SharedPreferencesUtils.getIP(this) + UPDATE_CAR_STATUS);
        OkGo.<String>post(SharedPreferencesUtils.getIP(this) + UPDATE_CAR_STATUS)
                .tag(this)
                .upJson(jsonStr22)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body().trim();
                        UtilsLog.e("updateCarStatusInfor-result==" + result);
                        UtilsLog.e("updateCarStatusInfor-result=22=" + result.substring(1, result.length() -
                                1));
                        String logStr = "\n" + "车辆唯一性检查--外检项目更新状态--onSuccess" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(instances) +
                                UPDATE_CAR_STATUS + "\n" + "JSON::" + jsonStr22 + "\n" + "result::" +
                                response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        CommonUtils.hideLoadingDialog(instances);
                        String newResult = result.substring(1, result.length() - 1).replaceAll("\\\\", "");
                        if ("ok".equalsIgnoreCase(newResult)) {
                            getDataWaiJainEnd();
//                            Handler handler = new Handler();
//                            handler.postDelayed(new Runnable() {
//                                @Override
//                                public void run() {
//                                    getDataWaiJainEnd();
//                                }
//                            }, 800);//后执行Runnable中的run方法
                        } else {
                            MessageDialog.show(instances, "提示", "更新车辆状态失败，请重试", "确定");
                        }
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        UtilsLog.e("getDataWaiJainStart-onError==" + response.body());
                        String logStr = "\n" + "车辆唯一性检查--外检项目更新状态-onError-失败" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(instances) +
                                UPDATE_CAR_STATUS + "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        CommonUtils.hideLoadingDialog(instances);
                    }
                });
    }


    String setBuHeGeItem() {
        String myjson = "";
        CodeListModel codeListModel = null;
        List<CodeListModel> codeList_list = new ArrayList<>();
        codeListModel = new CodeListModel();
        codeListModel.setDataType("UC");
        codeListModel.setGUID(carsInforModel.getGUID());
        codeListModel.setUCResultNote(desc);
        codeListModel.setDetection_ID(String.valueOf(carsInforModel.getID()));
        codeListModel.setTest_times(carsInforModel.getTimes());
        codeListModel.setUnqualified_Code1("0");
        codeListModel.setUnqualified_Code2("0");
        codeListModel.setUnqualified_Code3("0");
        codeList_list.add(codeListModel);
        Gson gson = new Gson();
        String jsonStr = gson.toJson(codeList_list);
//            myjson = "[{" + jsonStr.substring(1, jsonStr.length() - 1) + "}]";
        myjson = jsonStr;
        UtilsLog.e("车辆唯一性检查--reportedJsonStr555==" + myjson);
        return myjson;
    }

    //外检不合格项目-增加外检记录接口
    private void uploadBuHeGeData() {
//        Gson gson = new Gson();
//        String jsonStr = setBuHeGeItem();
        String jsonStr = reportedJsonStr3();
        UtilsLog.e("车辆唯一性检查--uploadDataByWaiJianItem---jsonStr==" + jsonStr);
        UtilsLog.e("车辆唯一性检查--uploadDataByWaiJianItem---url==" + SharedPreferencesUtils.getIP(this) + WAIJIAN_ADD_RECORED);
        String logStr = "\n" + "车辆唯一性检查--外检不合格项目-增加外检记录接口--uploadDataByWaiJianItem--请求" +
                "\n" + "URL::" + SharedPreferencesUtils.getIP(instances) +
                WAIJIAN_ADD_RECORED + "\n" + "JSON::" + jsonStr + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        OkGo.<String>post(SharedPreferencesUtils.getIP(this) + WAIJIAN_ADD_RECORED).tag(this)
                .upJson(jsonStr)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body();
                        UtilsLog.e("车辆唯一性检查--uploadDataByWaiJianItem-result==" + result);
                        String newResult = result.substring(1, result.length() - 1).replaceAll("\\\\", "");
                        UtilsLog.e("车辆唯一性检查--uploadDataByWaiJianItem-newResult==" + newResult);
                        CommonUtils.hideLoadingDialog(instances);
                        String logStrf = "\n" + "车辆唯一性检查--外检不合格项目-增加外检记录接口--uploadDataByWaiJianItem--请求成功" +
                                "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrf.getBytes());
                        if ("ok".equalsIgnoreCase(newResult)) {

                            //默认不进入--不合格项目--上传的数据；进入不合格项目则不调用
                            if (is_500 == false) {
                                uploadDataByWaiJianItem();
                            }
                            updateCarStatusInfor();
//                            Handler handler = new Handler();
//                            handler.postDelayed(new Runnable() {
//                                @Override
//                                public void run() {
//                                    updateCarStatusInfor();
////                                    uploadBuHeGeData();
//                                }
//                            }, 800);//后执行Runnable中的run方法
//                            instances.finish();
//                            Toast.makeText(instances, "提交成功", Toast
//                                    .LENGTH_LONG).show();
                        } else {
                            Toast.makeText(instances, "车辆唯一性检查项目数据提交失败，请重试", Toast
                                    .LENGTH_LONG).show();
                        }

                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        UtilsLog.e("车辆唯一性--uploadDataByWaiJianItem-onError==" + response.body());
                        CommonUtils.hideLoadingDialog(instances);
                        String logStr = "\n" + "车辆唯一性--外检不合格项目-增加外检记录接口--uploadDataByWaiJianItem-onError-失败" +
                                "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                    }
                });
    }

    /**
     * 项目总结束接口,最后一个执行
     */
    private void EndAllItem(final String detectionID) {
        UtilsLog.e("EndAllItem---url==" + SharedPreferencesUtils.getIP(instances) + ITEM_ALL_END +
                detectionID + "/DetectionID");
        String logStr = "\n" + "车辆唯一性检查--外检项目总结束:总结束:总结束--url" +
                "\n" + "URL::" + SharedPreferencesUtils.getIP(instances) +
                ITEM_ALL_END + detectionID + "/DetectionID" + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        OkGo.<String>get(SharedPreferencesUtils.getIP(instances) + ITEM_ALL_END +
                detectionID + "/DetectionID").tag(instances)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
                        CommonUtils.showLoadingDialog(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        CommonUtils.hideLoadingDialog(instances);
                        String result = response.body();
                        UtilsLog.e("EndAllItem-result==" + result);
                        String logStr = "\n" + "车辆唯一性检查--外检项目总结束:总结束:总结束--请求成功" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(instances) +
                                ITEM_ALL_END + detectionID + "/DetectionID" +
                                "\n" + "result::" + result;
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
//                        Toast.makeText(instances, "外检项目完成", Toast
//                                .LENGTH_LONG).show();

                        TipDialog.show(instances, "车辆唯一性检查结束成功", TipDialog.TYPE.SUCCESS);
                        Handler handler = new Handler();
                        handler.postDelayed(new Runnable() {
                            @Override
                            public void run() {
//                                    finish();
                                Intent intent = new Intent();
                                intent.putExtra("nq", 1);
                                instances.setResult(102, intent);
                                instances.finish();
                            }
                        }, 1000);//后执行Runnable中的run方法


//
//                        TipDialog.show(instances, "联网项目结束成功", TipDialog.TYPE.SUCCESS);
//                        Handler handler = new Handler();
//                        handler.postDelayed(new Runnable() {
//                            @Override
//                            public void run() {
//                                Intent intent = new Intent();
//                                intent.putExtra("nq", 1);
//                                instances.setResult(101, intent);
//                                instances.finish();
//                            }
//                        }, 1000);//后执行Runnable中的run方法
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        String logStr = "\n" + "车辆唯一性检查--外检项目总结束:总结束:总结束-onError-失败" +
                                "\n" + "URL::" + SharedPreferencesUtils.getIP(instances) +
                                ITEM_ALL_END + detectionID + "/DetectionID" +
                                "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                        UtilsLog.e("EndAllItem-onError==" + response.body());
                        UtilsLog.e("EndAllItem-onError==" + response.getException());
                        CommonUtils.hideLoadingDialog(instances);
                        MessageDialog.show(instances, "提示", "项目结束失败，请重试", "确定");
//                        showDialog("车辆下线失败，请重试，如果还未成功请联系管理员");
                    }
                });
    }

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (data != null) {
            switch (requestCode) {
                case 500:
                    List<CheckItemModel> list2 = (List<CheckItemModel>) data.getSerializableExtra("waiJianPhoto_buhege_List");
                    List<MyChoiceModel> waiJianPhoto_List = new ArrayList<>();//Code2选择的列表
                    if (list2 != null && list2.size() > 0) {
                        is_500 = true;
                        List<Item_2Model> Item_2Model_list = new ArrayList<>();//Code2去重后的所有数据
                        Item_2Model item_2 = null;
                        for (int i = 0; i < list2.size(); i++) {
                            item_2 = new Item_2Model();
                            item_2.setID(list2.get(i).getID());
                            item_2.setCode1(list2.get(i).getCode1());
                            item_2.setCode2(list2.get(i).getCode2());
                            item_2.setName2(list2.get(i).getName2());
                            item_2.setName3(list2.get(i).getName3());
                            item_2.setFlag(list2.get(i).getFlag());
                            Item_2Model_list.add(item_2);
                        }
                        for (int k = 0; k < Item_2Model_list.size() - 1; k++) {
                            for (int j = Item_2Model_list.size() - 1; j > k; j--) {
                                if (Item_2Model_list.get(j).getCode2().equals(Item_2Model_list.get(k).getCode2())) {
                                    Item_2Model_list.remove(j);
                                }
                            }
                        }

                        for (int i = 0; i < Item_2Model_list.size(); i++) {
                            MyChoiceModel model = new MyChoiceModel();
                            model.setCode2(Item_2Model_list.get(i).getCode2());
                            model.setChecked(true);
                            model.setName2(Item_2Model_list.get(i).getName2());
                            model.setName3(Item_2Model_list.get(i).getName3());
                            model.setCode_key("Code2-" + Item_2Model_list.get(i).getCode2());
                            model.setCode_values(Item_2Model_list.get(i).getFlag());
                            waiJianPhoto_List.add(model);
                        }
                        upload_code_str_500 = "";
//                        upload_code_str_names="";
                        for (int i = 0; i < waiJianPhoto_List.size(); i++) {
                            upload_code_str_500 = upload_code_str_500 + "\"" + waiJianPhoto_List.get(i).getCode_key() + "\""
                                    + ":" + "\"" + waiJianPhoto_List.get(i).getCode_values() + "\"" + ",";
//                            upload_code_str_names=upload_code_str_names+ ","+waiJianPhoto_List.get(i).getName3();
                        }
                        if (upload_code_str_500.length() > 0) {
                            upload_code_str_500 = upload_code_str_500.substring(0, upload_code_str_500.length() - 1);
                        }
//                        acUniquenessDesc.setText(upload_code_str_names);
                        UtilsLog.e("车辆唯一性--list2" + list2.toString());
                        String logStrfw = "\n" + "车辆唯一性--onActivityResult---500---list2" +
                                "\n" + "list2::" + list2.toString() + "\n";
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrfw.getBytes());
                    } else {
                        UtilsLog.e("车辆唯一性--list2====nulll==");
                        String logStrfw = "\n" + "车辆唯一性--onActivityResult---500---list2" +
                                "\n" + "list2====nulll==" + "\n";
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrfw.getBytes());
                    }
                    UtilsLog.e("车辆唯一性--list2====upload_code_str==" + upload_code_str_500);
                    String logStrfw = "\n" + "车辆唯一性--onActivityResult---500---upload_code_str_500" +
                            "\n" + "upload_code_str::" + upload_code_str_500 + "\n";
                    PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrfw.getBytes());
                    break;
                default:
                    break;
            }
        }
    }


    @Override
    protected void onResume() {
        super.onResume();
//        if (BaseApplication.BaseApplication_buHeGeModel3List != null
//                && BaseApplication.BaseApplication_buHeGeModel3List.size() > 0) {
//            String upload_code_str_names = "";
//            for (int i = 0; i < BaseApplication.BaseApplication_buHeGeModel3List.size(); i++) {
//                upload_code_str_names = upload_code_str_names+ BaseApplication.BaseApplication_buHeGeModel3List.get(i).getName3() + "," ;
//            }
//            if (upload_code_str_names.length() > 0) {
//                upload_code_str_names = upload_code_str_names.substring(0, upload_code_str_names.length() - 1);
//            }
////            acUniquenessDesc.setText(upload_code_str_names);
//            UtilsLog.e("BaseApplication_buHeGeModel3List==一二级目录==upload_code_str_names="+upload_code_str_names);
//            UtilsLog.e("BaseApplication_buHeGeModel3List==一二级目录=原始数据=" + BaseApplication.BaseApplication_buHeGeModel3List.toString());
//        } else {
//            UtilsLog.e("BaseApplication_buHeGeModel3List==一二级目录==nullllll=");
//        }
    }

    //组装要上报的json
    private String reportedJsonStr3() {
        if (TextUtils.isEmpty(BaseApplication.D_ItemStart_time) || BaseApplication.D_ItemStart_time.equals("")) {
            BaseApplication.D_ItemStart_time = DateUtil.currentTime2();
        }
        String myjson = "";
        CodeListModel codeListModel = null;
        List<CodeListModel> codeList_list = new ArrayList<>();
        if (BaseApplication.BaseApplication_buHeGeModel3List != null
                && BaseApplication.BaseApplication_buHeGeModel3List.size() > 0) {
            //去重
            Utils.removeDuplicate(BaseApplication.BaseApplication_buHeGeModel3List);

            if (BaseApplication.BaseApplication_buHeGeModel3List != null
                    && BaseApplication.BaseApplication_buHeGeModel3List.size() > 0) {
                for (int i = 0; i < BaseApplication.BaseApplication_buHeGeModel3List.size(); i++) {
                    UtilsLog.e("BaseApplication_buHeGeModel3List=去掉IsCheck==1后的数据=" +
                            BaseApplication.BaseApplication_buHeGeModel3List.toString());
                    if ("1".equals(BaseApplication.BaseApplication_buHeGeModel3List.get(i).getIsCheck())) {
                        codeListModel = new CodeListModel();
                        codeListModel.setDataType("UC");
                        codeListModel.setNQResultNote(desc);
                        codeListModel.setDetection_ID(String.valueOf(carsInforModel.getID()));
                        codeListModel.setTest_times(carsInforModel.getTimes());
                        codeListModel.setStart_Time(item_start_time);
                        codeListModel.setFinish_Time(DateUtil.currentTime2());
                        codeListModel.setTimes(carsInforModel.getTimes());
                        codeListModel.setGUID(carsInforModel.getGUID());
                        codeListModel.setUnqualified_Code1(BaseApplication.BaseApplication_buHeGeModel3List.get(i).getCode1());
                        codeListModel.setUnqualified_Code2(BaseApplication.BaseApplication_buHeGeModel3List.get(i).getCode2());
                        codeListModel.setUnqualified_Code3(BaseApplication.BaseApplication_buHeGeModel3List.get(i).getCode3());
                        codeList_list.add(codeListModel);
                    }
                }
                Gson gson = new Gson();
                String jsonStr = gson.toJson(codeList_list);
//            myjson = "[{" + jsonStr.substring(1, jsonStr.length() - 1) + "}]";
                myjson = jsonStr;
                UtilsLog.e("车辆唯一性检查-底盘动态--选择后的-reportedJsonStr3333==" + myjson);
            } else {
                codeListModel = new CodeListModel();
                codeListModel.setDataType("UC");
                codeListModel.setNQResultNote(desc);
                codeListModel.setDetection_ID(String.valueOf(carsInforModel.getID()));
                codeListModel.setTest_times(carsInforModel.getTimes());
                codeListModel.setStart_Time(item_start_time);
                codeListModel.setFinish_Time(DateUtil.currentTime2());
                codeListModel.setGUID(carsInforModel.getGUID());
                codeListModel.setTimes(carsInforModel.getTimes());
                codeListModel.setUnqualified_Code1("0");
                codeListModel.setUnqualified_Code2("0");
                codeListModel.setUnqualified_Code3("0");
                codeList_list.add(codeListModel);
                Gson gson = new Gson();
                String jsonStr = gson.toJson(codeList_list);
//            myjson = "[{" + jsonStr.substring(1, jsonStr.length() - 1) + "}]";
                myjson = jsonStr;
                UtilsLog.e("车辆唯一性检查-底盘动态--没有选择-reportedJsonStr4444==" + myjson);
            }
        } else {
            codeListModel = new CodeListModel();
            codeListModel.setDataType("UC");
            codeListModel.setNQResultNote(desc);
            codeListModel.setDetection_ID(String.valueOf(carsInforModel.getID()));
            codeListModel.setTest_times(carsInforModel.getTimes());
            codeListModel.setStart_Time(item_start_time);
            codeListModel.setFinish_Time(DateUtil.currentTime2());
            codeListModel.setGUID(carsInforModel.getGUID());
            codeListModel.setTimes(carsInforModel.getTimes());
            codeListModel.setUnqualified_Code1("0");
            codeListModel.setUnqualified_Code2("0");
            codeListModel.setUnqualified_Code3("0");
            codeList_list.add(codeListModel);
            Gson gson = new Gson();
            String jsonStr = gson.toJson(codeList_list);
//            myjson = "[{" + jsonStr.substring(1, jsonStr.length() - 1) + "}]";
            myjson = jsonStr;
            UtilsLog.e("车辆唯一性检查--底盘动态--默认值--reportedJsonStr555==" + myjson);
        }
        return myjson;
    }

    List<WaiJianAddRecordModel> WaiJianAddRecordModelList = new ArrayList<>();//外检增加记录list

    //不进入--不合格项目--默认上传的不合格项目数据
    private void setDataModel(List<Item_2Model> modelList) {
        if (WaiJianAddRecordModelList != null) {
            WaiJianAddRecordModelList.clear();
        }
        WaiJianAddRecordModelList = new ArrayList<>();
        for (int j = 0; j < modelList.size(); j++) {
            WaiJianAddRecordModel model = new WaiJianAddRecordModel();
            model.setDataType("F1_Record");
            model.setDetection_ID(String.valueOf(carsInforModel.getID()));
            model.setGUID(carsInforModel.getGUID());
            model.setTimes(carsInforModel.getTimes());
            model.setUnqualified_Code1(modelList.get(j).getCode1());
            model.setUnqualified_Code2(modelList.get(j).getCode2());
            model.setVerdict(modelList.get(j).getFlag());
            WaiJianAddRecordModelList.add(model);
        }
        String logStr = "\n" + "车辆唯一性检查-增加外检记录接口--setDataModel" +
                "\n" + "WaiJianAddRecordModelList::" + WaiJianAddRecordModelList.toString() + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        UtilsLog.e("车辆唯一性检查--setDataModel--WaiJianAddRecordModelList==" + WaiJianAddRecordModelList.toString());
    }

    //外检不合格项目-增加外检记录接口
    private void uploadDataByWaiJianItem() {
        Gson gson = new Gson();
        String jsonStr = gson.toJson(WaiJianAddRecordModelList);
        UtilsLog.e("车辆唯一性检查--外检不合格项目---jsonStr==" + jsonStr);
        UtilsLog.e("车辆唯一性检查--外检不合格项目---url==" + SharedPreferencesUtils.getIP(this) + WAIJIAN_ADD_RECORED);
        String logStr = "\n" + "车辆唯一性检查--外检不合格项目-增加外检记录接口--uploadDataByWaiJianItem--请求" +
                "\n" + "URL::" + SharedPreferencesUtils.getIP(instances) +
                WAIJIAN_ADD_RECORED + "\n" + "JSON::" + jsonStr + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        OkGo.<String>post(SharedPreferencesUtils.getIP(this) + WAIJIAN_ADD_RECORED).tag(this)
                .upJson(jsonStr)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body();
                        UtilsLog.e("车辆唯一性检查--外检不合格项目-result==" + result);
                        String newResult = result.substring(1, result.length() - 1).replaceAll("\\\\", "");
                        UtilsLog.e("车辆唯一性检查--外检不合格项目-newResult==" + newResult);
                        CommonUtils.hideLoadingDialog(instances);
//                        if ("ok".equalsIgnoreCase(newResult)) {
//                            Toast.makeText(instances, "提交成功", Toast.LENGTH_LONG).show();
//                            Intent intent = new Intent();
//                            intent.putExtra("waiJianPhoto_buhege_List", (Serializable) mycar_checkItemlList);
//                            instances.setResult(500, intent);
//                            instances.finish();
//                        } else {
//                            Toast.makeText(instances, "提交失败，请重试", Toast
//                                    .LENGTH_LONG).show();
//                        }
                        String logStrf = "\n" + "车辆唯一性检查--外检不合格项目-增加外检记录接口--uploadDataByWaiJianItem--请求成功" +
                                "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrf.getBytes());
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        UtilsLog.e("车辆唯一性检查--外检不合格项目-onError==" + response.body());
                        CommonUtils.hideLoadingDialog(instances);
                        String logStr = "\n" + "车辆唯一性检查--外检不合格项目-增加外检记录接口--uploadDataByWaiJianItem-onError-失败" +
                                "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                    }
                });
    }


    public  class WarningModel{
        String Type,UseProperty,RegisteDate;

        public String getType() {
            return Type;
        }

        public void setType(String type) {
            Type = type;
        }

        public String getUseProperty() {
            return UseProperty;
        }

        public void setUseProperty(String useProperty) {
            UseProperty = useProperty;
        }

        public String getRegisteDate() {
            return RegisteDate;
        }

        public void setRegisteDate(String registeDate) {
            RegisteDate = registeDate;
        }
    }

   //天津警告提示
    private void TianJin_warning() {
        WarningModel model =new WarningModel();
        model.setType(carsInforModel.getType());
        model.setUseProperty(carsInforModel.getUseProperty());
        String registerTime = carsInforModel.getRegisteDate();
        String str = registerTime.substring(6, registerTime.length() - 2).trim();
        String registerdate = DateUtil.getDateTimeFromMillisecond(Long.parseLong(str));
        model.setRegisteDate(registerdate);
        Gson gson = new Gson();
        String jsonStr = gson.toJson(model);
        UtilsLog.e("车辆唯一性检查--天津警告提示---jsonStr==" + jsonStr);
        UtilsLog.e("车辆唯一性检查--天津警告提示---url==" + SharedPreferencesUtils.getIP(this) + TIANJIAN_WARING);
        String logStr = "\n" + "车辆唯一性检查--天津警告提示--请求" +
                "\n" + "URL::" + SharedPreferencesUtils.getIP(instances) +
                TIANJIAN_WARING + "\n" + "JSON::" + jsonStr + "\n";
        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
        OkGo.<String>post(SharedPreferencesUtils.getIP(this) + TIANJIAN_WARING).tag(this)
                .upJson(jsonStr)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request<String, ? extends Request> request) {
                        super.onStart(request);
//                        CommonUtils.showLoadingDialog(instances, "加载中...");
                    }

                    @Override
                    public void onSuccess(Response<String> response) {
                        String result = response.body();
                        UtilsLog.e("车辆唯一性检查--天津警告提示-result==" + result);
                        String newResult = result.substring(1, result.length() - 1).replaceAll("\\\\", "");
                        UtilsLog.e("车辆唯一性检查--天津警告提示-newResult==" + newResult);
//                        CommonUtils.hideLoadingDialog(instances);
                        if (!TextUtils.isEmpty(newResult)) {
                            Toast.makeText(instances, "该车为老旧车，请严格把关", Toast.LENGTH_LONG).show();
//                            MessageDialog.show(instances,"警告提示","该车为老旧车，请严格把关");
//                            Toast.makeText(instances, "提交成功", Toast.LENGTH_LONG).show();
//                            Intent intent = new Intent();
//                            intent.putExtra("waiJianPhoto_buhege_List", (Serializable) mycar_checkItemlList);
//                            instances.setResult(500, intent);
//                            instances.finish();
                        } else {
//                            Toast.makeText(instances, "提交失败，请重试", Toast
//                                    .LENGTH_LONG).show();
                        }
                        String logStrf = "\n" + "车辆唯一性检查--天津警告提示--请求成功" +
                                "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStrf.getBytes());
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                        UtilsLog.e("车辆唯一性检查--天津警告提示-onError==" + response.body());
//                        CommonUtils.hideLoadingDialog(instances);
                        String logStr = "\n" + "车辆唯一性检查--天津警告提示-失败" +
                                "\n" + "result::" + response.body();
                        PDALogUtils.createLogFile(BaseApplication.JIANCE_MODE, logStr.getBytes());
                    }
                });
    }
}
